class Solution {
public:
  // 类两数之和，在哈希中查找nums[i]-dif 和 nums[i]-2*dif
    int arithmeticTriplets(vector<int>& nums, int diff) {
        unordered_map<int, bool> um;
        int cnt = 0;
        for(int i : nums){
            um[i] = true;
            if(um[i-diff] && um[i-2*diff]){
                ++cnt;
            }
        }
        return cnt;
    }

};